﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Shop.Controllers
{
    public class LoginController : Controller
    {
        // GET: Login
        Shop.Service.LoginService.LoginService service = new Service.LoginService.LoginService();
        public ActionResult Index()//登陆
        {
            return View();
        }
        #region  //主页验证登陆
        public JsonResult Login(string AdminName,string AdminPassw)
        {
            var loginVerification = service.Getlogin(AdminName, AdminPassw);
            if (loginVerification==null)
            {
                return Json( new { stauts = 0, Meg ="登陆失败！"});
            }
            else
            {
                Session["Admin1"] = loginVerification;
                return Json(new { stauts = 1 });
            }
            
        }
        #endregion
        #region//获得登陆用户名
        public ActionResult HomePage()
        {
            var admin1 = (List<Shop.Domain.NewFolder1.Administrator1Model>)Session["Admin1"];
            if (admin1 == null)
            {
                return RedirectToAction("Index");
            }
            ViewBag.Admin1 = admin1;
            Session["Admin1"] = admin1;
            return View();
        }
        #endregion
    }
}